home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d3 / rettig.arc / TRSOURCE.EXE / FILEATTR.ASM < prev    next >
Assembly Source File  |  1990-10-22  |  4KB  |  146 lines

  1. ; FILEATTR.ASM
  2. ;
  3. ; by Ralph Davis
  4. ; modified by Rick Spence, Leonard Zerman
  5. ;
  6. ; Placed in the public domain by Tom Rettig Associates, 10/22/1990.
  7. ;
  8.  
  9.         PUBLIC  _FILEATTR
  10.  
  11. READ_ONLY  EQU     1H
  12. HIDDEN     EQU     2H
  13. SYSTEM     EQU     4H
  14. ARCHIVE    EQU    20H
  15.  
  16. ;=========================
  17. ;
  18. IN_PARMS   STRUC
  19. ;
  20. OLD_BP     DW     ?
  21. RET_ADDR   DD     ?
  22. FILENAME   DD     ?
  23. ATTRIBS    DD     ?
  24. ;
  25. IN_PARMS   ENDS
  26. ;
  27. ;==========================
  28.  
  29.  
  30. ;******************************************
  31. FILEATTR_TEXT SEGMENT BYTE PUBLIC 'CODE'
  32.         ASSUME  CS:FILEATTR_TEXT
  33. ;-------------------------------------------
  34. ;
  35. ; This procedure turns the requested file attribute
  36. ; on or off.
  37. ;
  38. ;    Syntax:  CALL fileattr WITH filename,attributes,'+'/'-'
  39. ;    Return:  No return
  40. ;
  41. ;------------------------
  42. _FILEATTR  PROC FAR
  43.         PUSH    BP
  44.         MOV     BP,SP
  45.         PUSH    BX
  46.         PUSH    CX
  47.         PUSH    DX
  48.         PUSH    DS
  49.         PUSH    SI
  50.         PUSH    DI
  51.         LDS     SI,[BP].FILENAME  ; Get address of file name passed
  52.         PUSH    DS
  53.         PUSH    SI
  54.         MOV     AH,43H   ; Change file mode
  55.         MOV     AL,0     ; Get current mode
  56.         MOV     DX,SI
  57.         INT     21H
  58.         JNC     FILE_FOUND
  59.         POP     SI
  60.         POP     DS
  61.         XOR     AX,AX
  62.         DEC     AX          ; Return -1 for error
  63.         JMP     SHORT EXIT
  64. FILE_FOUND:
  65.         LDS     SI,[BP].ATTRIBS   ; Pick up +\-
  66.         CMP     BYTE PTR [SI],'+' ; First character must be + or -
  67.         JNE     FF_2
  68.         XOR     BX,BX             ; Mask for exclusive ORing
  69.         JMP     SHORT GET_ATTR2
  70. FF_2:
  71.         CMP     BYTE PTR [SI],'-' ; Not +, is it -?
  72.         JE      GET_ATTR1         ; First character -,clear attribute
  73.         POP     SI                ; Invalid first character, exit
  74.         POP     DS
  75.         XOR     AX,AX
  76.         DEC     AX                ; Return -1 for error
  77.         JMP     SHORT EXIT
  78. GET_ATTR1:
  79.         MOV     BX,0FFFFH         ; Mask for exclusive ORing
  80. GET_ATTR2:
  81.         INC     SI         ; Point to next character
  82.         MOV     AL,[SI]
  83.         OR      AL,AL
  84.         JZ      CHANGE_IT
  85.         CMP     AL,'+'
  86.         JNE     IS_IT_MINUS
  87.         XOR     BX,BX      ; Set up mask for exclusive ORing
  88.         JMP     SHORT GET_ATTR2
  89. IS_IT_MINUS:
  90.         CMP     AL,'-'
  91.         JNE     IS_ARCHIVE
  92.         MOV     BX,0FFFFH
  93.         JMP     SHORT GET_ATTR2
  94.         AND     AL,0DFH    ; Force to capital letter
  95.  
  96. IS_ARCHIVE:
  97.         AND     AL,0DFH    ; Convert to upper-case
  98.         CMP     AL,'A'     ; Archive?
  99.         JNE     IS_HIDDEN  ; No
  100.         MOV     DX,ARCHIVE ; Pick up mask
  101.         JMP     SHORT SET_ATTR
  102. IS_HIDDEN:
  103.         CMP     AL,'H'     ; Hidden?
  104.         JNE     IS_RDONLY  ; No
  105.         MOV     DX,HIDDEN  ; Pick up mask
  106.         JMP     SHORT SET_ATTR
  107. IS_RDONLY:
  108.         CMP     AL,'R'     ; Read only?
  109.         JNE     IS_SYSTEM  ; No
  110.         MOV     DX,READ_ONLY ; Pick up mask
  111.         JMP     SHORT SET_ATTR
  112. IS_SYSTEM:
  113.         CMP     AL,'S'     ; System?
  114.         JNE     GET_ATTR2  ; No, invalid character
  115.         MOV     DX,SYSTEM  ; Pick up mask
  116. SET_ATTR:
  117.         XOR     DX,BX      ; Turn attribute bit on or off
  118.         TEST    BX,0FFFFH    ; Are we turning bit on or off?
  119.         JNZ     CLEAR_ATTR   ; All FFFFs means turn it off
  120.         OR      CX,DX        ; Set attribute bit
  121.         JMP     SHORT GET_ATTR2
  122. CLEAR_ATTR:
  123.         AND     CX,DX        ; Clear attribute bit
  124.         JMP     SHORT GET_ATTR2
  125. CHANGE_IT:
  126.         POP     DX           ; Retrieve address of filename
  127.         POP     DS          
  128.         MOV     AH,43H       ; Change mode
  129.         MOV     AL,1         ; Set attribute
  130.         INT     21H
  131.         XOR     AX,AX        ; Return 0 for successful completion
  132. EXIT:   POP     DI
  133.         POP     SI
  134.         POP     DS
  135.         POP     DX
  136.         POP     CX
  137.         POP     BX
  138.         POP     BP
  139.         RET
  140. _FILEATTR ENDP
  141. ;----------------------------------------
  142. FILEATTR_TEXT   ENDS
  143. ;*******************************************************
  144.         END  
  145.  
  146.